home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 07 - 1991 / 07.12 Dec 91 / Transfer Menu Code / Transfer List.p < prev    next >
Encoding:
Text File  |  1988-12-28  |  2.9 KB  |  108 lines  |  [TEXT/MPS ]

  1. (*******************************************************************
  2.     
  3.     Transfer List.p
  4.     
  5.     LDEF for dynamic Transfer menu demo.
  6.     
  7.     (c) 1988, by Clifford Story & Attic Software
  8.     
  9. *******************************************************************)
  10.     
  11. unit Transferlist;
  12.     
  13. (******************************************************************)
  14.     
  15. interface
  16.     
  17. (******************************************************************)
  18.     
  19.     uses memtypes, quickdraw, osintf, toolintf, packintf, Common;
  20.     
  21. (******************************************************************)
  22.     
  23.     procedure listdef(message : integer; select : logical;
  24.                     therect : Rect; thecell : Cell; dataoffset : integer;
  25.                     datalen : integer; thelist : ListHandle);
  26.     
  27. (******************************************************************)
  28.     
  29. implementation
  30.     
  31. (******************************************************************)
  32.     
  33.     {$R-}
  34.     {$SC+}
  35.     
  36. (******************************************************************)
  37.     
  38.     procedure drawcell(thelist : ListHandle; therect : Rect;
  39.                     thecell: Cell; select : logical); forward;
  40.     
  41. (*******************************************************************
  42.     
  43.     listdef
  44.     -------
  45.     
  46.     An LDEF is called to do four different things:  initialize any
  47.     provate data structures; draw an element of the list; highlight
  48.     an element of the list; and dispose of any private data.  The
  49.     “message” parameter determines which service is requested.
  50.     
  51.     I have never known an LDEF that used private data, and
  52.     highlighting is usually done by simply inverting the element's
  53.     rectangle, so about all an LDEF has to do is draw.
  54.     
  55. *******************************************************************)
  56.     
  57.     procedure listdef(message : integer; select : logical;
  58.                     therect : Rect; thecell : Cell; dataoffset : integer;
  59.                     datalen : integer; thelist : ListHandle);
  60.  
  61.         begin
  62.             
  63.             case message of
  64.                 lInitMsg        :    ;
  65.                 lDrawMsg        :    drawcell(thelist, therect, thecell, select);
  66.                 lHiliteMsg    :    InvertRect(therect);
  67.                 lCloseMsg    :    ;
  68.             end;
  69.         
  70.         end;
  71.     
  72. (*******************************************************************
  73.     
  74.     drawcell
  75.     --------
  76.     
  77.     This routine draws one element in the list.  It's a good example
  78.     of why you should always write your own LDEF instead of using
  79.     the standard LDEF 0.  LDEF's are very easy to write, and you can
  80.     shape yours to fit the data.  LDEF 0, on the other hand, has to
  81.     be very general, and has to be spoon-fed the data.
  82.     
  83. *******************************************************************)
  84.     
  85.     procedure drawcell(thelist : ListHandle; therect : Rect;
  86.                     thecell : Cell; select : logical);
  87.         
  88.         var
  89.             thehandle        :    thandle;
  90.         
  91.         begin
  92.             
  93.             thehandle := thandle(GetResource('TRNS', 1001));
  94.             
  95.             MoveTo(therect.left + 4, therect.bottom - 4);
  96.             DrawString(thehandle^^.appl[thecell.v + 1].name);
  97.             
  98.             if select then
  99.                 InvertRect(therect);
  100.         
  101.         end;
  102.     
  103. (******************************************************************)
  104.     
  105.     end.
  106.     
  107. (******************************************************************)
  108.